import { request } from "./request"

//获取用户列表
export async function getHttpUserList(queryInfo) {
  return await request({
    method: "get",
    url: "users",
    params: queryInfo
  })
}

//修改用户状态
export async function putHttpUserState(userinfo) {
  return await request({
    method: "put",
    url: `users/${userinfo.id}/state/${userinfo.mg_state}`
  })
}

//修改用户信息
export async function putHttpUserInfo(userinfo) {
  return await request({
    method: "put",
    url: `users/${userinfo.id}`,
    data: userinfo
  })
}

//删除单个用户
export async function deleteHttpDeleteUserById(id) {
  return await request({
    method: "delete",
    url: `users/${id}`
  })
}

//添加用户
export async function postHttpAddUser(userinfo) {
  return await request({
    method: "post",
    url: "users",
    data: userinfo
  })
}

//根据 ID 查询用户信息
export async function getHttpGetUser(id) {
  return await request({
    method: "get",
    url: "users/"+id
  })
}

//分配用户角色
export async function putHttpUpdateUserRole(userid,rid) {
  return await request({
    method: "put",
    url: 'users/'+ userid +'/role',
    data: {
      rid: rid
    }
  })
}